package com.church.services;

import java.util.Date;
import java.util.List;

import com.church.dao.CurriculumDao;
import com.church.db.Curriculum;

public class CurriculumServicesImpl implements CurriculumServices {
	private CurriculumDao curriculumDao;

	public CurriculumDao getCurriculumDao() {
		return curriculumDao;
	}

	public void setCurriculumDao(CurriculumDao curriculumDao) {
		this.curriculumDao = curriculumDao;
	}

	@Override
	public List<Curriculum> getByDate(Date date) {
		return curriculumDao.findByDate(date);
	}

	@Override
	public String add(Curriculum curriculum) {
		return curriculumDao.add(curriculum);
	}

	@Override
	public String remove(long id) {
		Curriculum curriculum = curriculumDao.findById(id);
		if (curriculum != null) {
			curriculum.setState("3");
			return curriculumDao.update(curriculum);
		}

		return "error";
	}
}
